package metalink.admin;

import java.util.ArrayList;

import vo.DepartmentDetailsVo;
import vo.mixed.CourseListVo;
import model.admin.GetListsMo;
import model.admin.ModifyCoursesMo;
import model.admin.ModifyDepartmentsMo;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class ModifyDepartmentDetails extends ActionSupport {
	int batch_id;
	int department_id;
	String department_name;
	String description;
	int start_year;
	ArrayList<String> department_list;
	ArrayList<Integer> year_list;
	String course_selected;
	ArrayList<String> course_list;

	public ArrayList<Integer> getYear_list() {
		return year_list;
	}

	public void setYear_list(ArrayList<Integer> year_list) {
		this.year_list = year_list;
	}

	public int getDepartment_id() {
		return department_id;
	}


	public ArrayList<String> getDepartment_list() {
		return department_list;
	}

	public void setDepartment_list(ArrayList<String> department_list) {
		this.department_list = department_list;
	}

	public ArrayList<String> getCourse_list() {
		return course_list;
	}

	public void setCourse_list(ArrayList<String> course_list) {
		this.course_list = course_list;
	}

	public int getBatch_id() {
		return batch_id;
	}

	public void setBatch_id(int batch_id) {
		this.batch_id = batch_id;
	}

	public int getStart_year() {
		return start_year;
	}

	public void setStart_year(int start_year) {
		this.start_year = start_year;
	}

	public void setDepartment_id(int department_id) {
		this.department_id = department_id;
	}

	public String getDepartment_name() {
		return department_name;
	}

	public void setDepartment_name(String department_name) {
		this.department_name = department_name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String updateBatchDepartmentDetails() {
		System.out.println("HiiiiiR");
		ModifyDepartmentsMo single_object = new ModifyDepartmentsMo();
		System.out.println(department_id + " dept id \t");
		DepartmentDetailsVo department_details = new DepartmentDetailsVo();
		department_details.setDepartment_id(getDepartment_id());
		System.out.println(department_details.getDepartment_id() + " set \n");
		department_details.setDepartment_name(getDepartment_name());
		department_details.setDescription(getDescription());
		if (single_object.updateDepartmentDetails(department_details))
			return "success";
		else
			return "error";
	}

	public String deleteBatchDepartmentDetails() {
		ModifyDepartmentsMo deleteObj = new ModifyDepartmentsMo();
		deleteObj.deleteDepartmentDetails(batch_id, department_id);
		return SUCCESS;
	}

	public String addBatchDepartmentDetails() {
		GetListsMo list = new GetListsMo();
		setDepartment_list(list.getDepartmentList());
		setYear_list(list.GetYearList());
		return SUCCESS;
	}

	public String submitBatchDepartmentDetails() {
		ModifyDepartmentsMo single_obj = new ModifyDepartmentsMo();
		single_obj.addBatchDepartmentDetails(department_name, description,
				batch_id, start_year);
		System.out.println("batch id  " + batch_id + "\t start year "
				+ start_year);
		return SUCCESS;
	}

	public String addDepartmentDetails() {
		ModifyDepartmentsMo m = new ModifyDepartmentsMo();
		DepartmentDetailsVo department = new DepartmentDetailsVo();
		department.setDepartment_name(department_name);
		department.setDescription(description);
		department.setStart_year(start_year);
		m.addNewDepartment(department);
		return SUCCESS;
	}

	public String execute() {
		return SUCCESS;
	}

	public String deleteDepartmentDetails() {
		ModifyDepartmentsMo deleteObj = new ModifyDepartmentsMo();
		deleteObj.deleteDepartmentDetails(0, department_id);
		return SUCCESS;
	}

	public String addNewDepartmentCourse() {
		GetListsMo m = new GetListsMo();
		setCourse_list(m.getAllCourses());
		return SUCCESS;
	}

	public String submitNewDepartmentCourse() {

		ModifyCoursesMo m= new ModifyCoursesMo();
		CourseListVo c= new CourseListVo();
		m.addDepartmentCourseDetails(department_id, course_selected);
		return SUCCESS;
	}
}
